import Vue from "vue";
import Vuex from "vuex"

const actions = {
    setUsername(context,username){
        context.commit("SET_USER_NAME", username);
    },

    setTabList(context,tableList) {
        context.commit("SET_TAB_LIST", tableList);
    },
    removeTab(context,index) {
        context.commit("REMOVE_TAB", index);
    }
};
const mutations = {
    SET_TAB_LIST(state,value) {
        state.tabList.push(value);
    },
    SET_USER_NAME(state,value){
        state.username = value;
    },
    REMOVE_TAB(state,index) {
        state.tabList.splice(index, 1);
    }
};
const state = {
    tabList: [],
    username:""
};
Vue.use(Vuex);
export default new Vuex.Store({
    actions,
    state,
    mutations
})
